#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_LEN 20

void loop_move(char *pstr, int steps)
{
	int n = strlen(pstr) - steps;
	char tmp[MAX_LEN];
	
	strcpy(tmp, pstr + n);	
	strcpy(tmp + steps, pstr);	
	*(tmp + strlen(pstr)) = '\0';
	strcpy(pstr, tmp);
}

void loop_m(char *pstr, int steps)
{
	int n = strlen(pstr) - steps;
	char tmp[MAX_LEN];
	
	memcpy(tmp, pstr + n, steps);
	
	memcpy(pstr + steps, pstr, n);
	printf("t %s\n", pstr);
	
	memcpy(pstr, tmp, steps);
	printf("t %s\n", pstr);
}

int main()
{
	char str[10] = "xiaozhi";
	char *p = str;
	
	loop_move(str, 2);	
	//loop_m(str, 2);
	printf("%s\n", p);
}
